package com.example.travelhelper.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.travelhelper.pojo.CustomerService;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Mapper
public interface CustomerSeMapper extends BaseMapper<CustomerService> {
    @Insert("INSERT INTO customer_service (cs_id, cs_username,cs_telephone) " +
            "VALUES (#{csId},#{csUsername},#{csTelephone}) ")
    void addCustomerSe( CustomerService customerService);

    @Select("select * from customer_service where cs_telephone=#{csTelephone}")
    CustomerService selectByPhone(String csTelephone);

    @Select("select * from customer_service where cs_telephone=#{csTelephone} and cs_state=1")
    CustomerService selectByPhoneandState(String csTelephone);

    @Select("select * from customer_service where cs_id=#{csId}")
    CustomerService selectById(String csId);

    @Update("update customer_service set cs_state=#{csState} where cs_id = #{csId}")
    public int updateCsState(@Param("csState") int csState,@Param("csId") String csId);

    @Select("select * from customer_service where cs_state = 1")
    @ResultType(CustomerService.class)
    public List<CustomerService> listAllByCsState();
}
